package harvard.cscie160.hw7.project;
import java.rmi.Naming;


/**
 * 
 * @author M Bret Blackford
 *
 */
public class ATMServer {

public static void main(String[] args) {
		{
			String bankService = "//localhost/bank";
			String atmService = "//localhost/atmfactory";
			
			System.out.println();
			System.out.println();
			
			try {
				BankInterface bank = (BankInterface) Naming.lookup(bankService);
				if (bank == null) {
					throw new Exception(bankService + " not found in registry");
				}
				System.out.println("BankIntf found in registry");

				ATMFactoryImpl obj = new ATMFactoryImpl(bank);
				Naming.rebind(atmService, obj);
				
				System.out.println(DateUtils.now() +  " ATMFactoryImpl bound in registry ");
				System.out.println(DateUtils.now() +  " ATMFactoryImpl bound as " + atmService);
			} catch (Exception e) {
				System.out.println("ATMFactoryImpl error: " + e.getMessage());
				e.printStackTrace();
			}
		}
	}

}
